package com.fyt.ZhongYaoApp.config;

//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.security.authentication.AuthenticationManager;
//import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.http.SessionCreationPolicy;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//import org.springframework.security.crypto.password.PasswordEncoder;
//import org.springframework.security.web.SecurityFilterChain;
//import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;

//@Configuration
//public class SecurityConfig{
//    @Autowired
//    AuthenticationConfiguration authenticationConfiguration;//获取AuthenticationManager
//
//    @Bean
//    public PasswordEncoder passwordEncoder() {
//        return new BCryptPasswordEncoder();
//    }
//    @Bean
//    public AuthenticationManager authenticationManagerBean() throws Exception {
//        return authenticationConfiguration.getAuthenticationManager();
//    }
//
//    // 登录请求放行
//    @Bean
//    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
//        //配置关闭csrf机制
//        http.csrf(csrf -> csrf.disable());
//        //配置请求拦截方式
//        //permitAll:随意访问
//        http.authorizeHttpRequests(auth -> auth.requestMatchers("/user/login", "/user/register", "/webjars/**", "/swagger-ui/**", "/v3/api-docs/**", "/swagger-ui.html","/doc.html","http://localhost:8080/swagger-ui/index.html#/")
//                .permitAll().
//                anyRequest()// 其他所有请求
//                .authenticated());// 进行身份校验
//        //把token校验过滤器添加到过滤器链中
////        http.addFilterBefore(jwtAuthenticationTokenFilter,
////                UsernamePasswordAuthenticationFilter.class);
//        return http.build();
//    }
//
//
//
//}
